<?php
	include "./addons/Wechat/config/config.php";
	include "./addons/Wechat/expand/common.html";
?>


<div id="lywq_Wechat" class="lywq_Wechat_cox" style="display:none">
	<div class="lywq_Wechat_tc">
		<?php
			echo '<img src="' .$lywq['Wechat']['gzhimage']. '" width="100%" />';
		?>
		<div class="Wechat-tip">
		    <span class="Wechat-desc">微信扫描上方二维码关注微信公众号</span>
		    <p>发送“<span style="color:red;"><?php echo $lywq['Wechat']['passwordkey'];?></span>”，即可获取观影密码</p>
		</div>
		<input type="text" id="pwd" class="Wechat-btn" placeholder="请输入密码">
		<a onclick="checkpwd()" class="Wechat-btn">确定</a>
	</div>
</div>
<style>
.lywq_Wechat_cox {position: fixed;width: 100%;height: 100%;background: rgba(0, 0, 0, 0.2);display: none;top: 0;right: 0;bottom: 0;left: 0;overflow: hidden;outline: 0;-webkit-overflow-scrolling: touch;background-color: rgb(0, 0, 0);filter: alpha(opacity=60);background-color: rgba(0, 0, 0, 0.6);z-index: 9999;}
.lywq_Wechat_tc{width: 360px;height: 560px;border: 5px solid #FFA500;border-radius: 10px;position:fixed;top:-30px;right:0;left:0;bottom:0;margin:auto;background: #fff;}
.Wechat-tip{margin:0 auto;width:290px;text-align:center;font-size:15px;color:#2466f4;background:url() left center/auto 15px repeat-x}
.Wechat-tip .Wechat-desc{background-color:#fff;padding:0 5px}
.Wechat-btn{display:block;width:214px;height:40px;line-height:40px;margin:18px auto 0 auto;text-align:center;font-size:18px;color:#2466f4;border-radius:20px;border:.5px #2466f4 solid;text-decoration:none}
</style>
<script type="text/javascript">
if (browser.versions.mobile) {
        if(browser.versions.android && !browser.versions.bsl){
            if('<?php echo $lywq['Wechat']['terminal'];?>'.indexOf('android')!==-1){
            	pwdController();
            }
    	}
        if (browser.versions.ios) {
            if('<?php echo $lywq['Wechat']['terminal'];?>'.indexOf('ios')!==-1){
            	pwdController();
            }
        }
        if (browser.versions.weixin) {
            if('<?php echo $lywq['Wechat']['terminal'];?>'.indexOf('weixin')!==-1){
            	pwdController();
            }
        }
        if (browser.versions.qq) {
            if('<?php echo $lywq['Wechat']['terminal'];?>'.indexOf('qq')!==-1){
            	pwdController();
            }
        }
        if (browser.versions.bsl) {
            if('<?php echo $lywq['Wechat']['terminal'];?>'.indexOf('bsl')!==-1){
            	pwdController();
            }
        }
}else{
    if('<?php echo $lywq['Wechat']['terminal'];?>'.indexOf('pc')!==-1){
    	pwdController();
    }
}
function pwdController(){
	if( (<?php echo $lywq['Wechat']['passwordstatus'];?> == 1) && (checkCookie('Wechat_pwd') == false) ){
		var div=document.getElementById("lywq_Wechat");
		div.style.display="block"
	}
}
function checkpwd(){
	var pwd = document.getElementById("pwd").value;
	if(pwd == '<?php echo $lywq['Wechat']['passwordtext'];?>'){
		setCookie('Wechat_pwd',true,360);
		var div=document.getElementById("lywq_Wechat");
		div.style.display="none";
	}
	if(pwd != '<?php echo $lywq['Wechat']['passwordtext'];?>'){
		alert('密码错误！');
	}
}
function RndPassword(){
    var url = '//'+document.domain+'/addons/Wechat/config/RndPassword.php?token=<?php echo $lywq['Wechat']['token'];?>&type=1';
    var httpRequest = new XMLHttpRequest();
    httpRequest.open('GET', url, true);
	httpRequest.timeout = 0;
    httpRequest.send();
}
RndPassword();
</script>
